package mn.slide.labmed.database;
import java.sql.SQLException;
import java.util.List;

import mn.slide.labmed.model.Model;
import android.content.Context;

public class DatabaseManager
{
	static private DatabaseManager	instance;

	static public void init( Context ctx )
	{
		if (null == instance)
		{
			instance = new DatabaseManager(ctx);
		}
	}

	static public DatabaseManager getInstance()
	{
		return instance;
	}

	private DatabaseHelper	helper;

	private DatabaseManager( Context ctx )
	{
		helper = new DatabaseHelper(ctx);
	}

	private DatabaseHelper getHelper()
	{
		return helper;
	}

	public void upgradeDataBase()
	{
		helper.upgrade();
	}

	public List<Model> getListModel()
	{
		List<Model> model = null;
		try
		{
			model = getHelper().getModelDao().queryForAll();
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}
		return model;
	}

}
